StaffPositionForm = Ext
		.extend(
				Ext.Window,
				{
					constructor : function(a) {
						Ext.applyIf(this, a);
						this.initUIComponents();
						StaffPositionForm.superclass.constructor.call(this, {
							id : "StaffPositionFormWin",
							layout : "fit",
							iconCls : "menu-job",
							items : this.formPanel,
							modal : true,
							height : 150,
							minHeight : 150,
							width : 350,
							minWidth : 300,
							maximizable : true,
							title : this.positionName == null ? "新增/编辑职位人员信息"
									: "新增/编辑职位[" + this.positionName + "]人员信息",
							buttonAlign : "center",
							buttons : [ {
								text : "保存",
								iconCls : "btn-save",
								scope : this,
								handler : this.save
							}, {
								text : "取消",
								iconCls : "btn-cancel",
								scope : this,
								handler : this.cancel
							} ],
							keys : {
								key : Ext.EventObject.ENTER,
								fn : this.save,
								scope : this
							}
						});
					},
					initUIComponents : function() {
						this.formPanel = new Ext.FormPanel(
								{
									layout : "form",
									bodyStyle : "padding:10px",
									border : false,
									id : "StaffPositionForm",
									defaults : {
										anchor : "96%,96%"
									},
									defaultType : "textfield",
									items : [
											{
												name : "staffPosition.id",
												xtype : "hidden",
												value : this.id == null ? ""
														: this.id
											},
											{
												name : "staffPosition.position.id",
												xtype : "hidden",
												id:"staffPositionPositionId",
												value : this.positionId == null ? ""
														: this.positionId
											},
											{
												name : "staffPosition.staff.id",
												id:"staffPositionStaffId",
												xtype : "hidden"
											},
											{
												xtype : "container",
												layout : "column",
												fieldLabel : "员工名称",
												style : "margin-bottom:5px;",
												items : [
														{
															columnWidth : 1.,
															xtype : "textfield",
															name : "staffPosition.staff.name",
															id:"staffPositionStaffName",
															readOnly : true,
															allowBlank : false,
															maxLength : 128
														},
														{
															xtype : "button",
															text : "请选择",
															iconCls : "btn-user-sel",
															handler : function() {
															UserSelector.getView(/*function(c,a) {
																
																					Ext.getCmp("staffPositionStaffId").setValue(
																									c[0].data.id);
																					Ext.getCmp("staffPositionStaffName").setValue(
																									c[0].data.name);
																				},
																				true*/
																	{callback:function(c,a) {
																		
																		Ext.getCmp("staffPositionStaffId").setValue(
																						c[0].data.id);
																		Ext.getCmp("staffPositionStaffName").setValue(
																						c[0].data.name);
																	}})
																		.show();
															}
//															disabled : this.staffPositionId == null ? false
//																	: true
														} ]
											},
										/*	{
												xtype : "container",
												layout : "column",
												fieldLabel : "员工职位",
												style : "margin-bottom:5px;",
												items : [
														{
															columnWidth : 0.99,
															xtype : "textfield",
															name : "staffPosition.job.jobName",
															readOnly : true,
															allowBlank : false,
															maxLength : 128,
															value : this.jobName != null ? this.jobName
																	: ""
														},
														{
															xtype : "button",
															text : "请选择",
															iconCls : "btn-job-sel",
															handler : function() {
																JobSelector
																		.getView(
																				function(
																						b,
																						a) {
																					var c = Ext
																							.getCmp("StaffPositionForm");
																					c
																							.getCmpByName(
																									"staffPosition.job.jobId")
																							.setValue(
																									b);
																					c
																							.getCmpByName(
																									"staffPosition.job.jobName")
																							.setValue(
																									a);
																				},
																				true)
																		.show();
															}
														} ]
											},*/
											{
												fieldLabel : "是否主职位",
												hiddenName : "staffPosition.isMain",
												displayField : "name",
												valueField : "id",							
												xtype : "combo",
												mode : "local",
												store : [ [ "1", "是" ] ,
												          [ "0", "否" ]],
												triggerAction : "all",
												editable : false,
												emptyText : "--请选择是否为主职位--",
												value : "1"
//												anchor : "99%"
											} ]
								});
						if (this.id != null
								&& this.id != "undefined") {
							this.formPanel.loadData({
								url : __ctxPath
										+ "/system/getStaffPos.do?id="
										+ this.id,
								root : "result",
								preName : "staffPosition",
								success:function(form,action){
									var obj = Ext.decode(form.responseText).result;
									Ext.getCmp("staffPositionPositionId").setValue(obj.position.id);
									Ext.getCmp("staffPositionStaffId").setValue(obj.staff.id);
									Ext.getCmp("staffPositionStaffName").setValue(obj.staff.name);
									
								}
							});
						}
					},
					cancel : function() {
						this.close();
					},
					save : function() {
						var a = this.formPanel;
						if (a.getForm().isValid()) {
							a
									.getForm()
									.submit(
											{
												url : __ctxPath
														+ "/system/saveStaffPos.do",
												method : "post",
												waitMsg : "数据正在，提交请稍后...",
												success : function(b, d) {
													var c = Ext
															.getCmp("StaffPositionStaffGrid");
													if (c != null) {
														c.getStore().reload();
													}
													Ext.ux.Toast.msg("操作提示",
															"数据保存成功！");
													Ext
															.getCmp(
																	"StaffPositionFormWin")
															.close();
												},
												failure : function(b, d) {
													var c = Ext.util.JSON
															.decode(d.response.responseText);
													Ext.ux.Toast.msg("操作提示",
															c.msg);
												}
											});
						}
					}
				});